package com.yytek.nmp.api;

import com.yytek.common.core.constant.ServiceNameConstants;
import com.yytek.common.core.domain.R;
import com.yytek.common.core.web.domain.AjaxResult;
import com.yytek.nmp.api.domain.SysJob;
//import com.yytek.nmp.api.factory.RemoteJobFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 任务业务相关
 */
@FeignClient(contextId = "remoteJobService", value = ServiceNameConstants.JOB_SERVICE)
public interface RemoteJobService {
    /**
     * 新增执行任务
     * @param job
     * @return
     */
    @PostMapping("/job/addApi")
    R addApi(@RequestBody SysJob job);

    /**
     * 更改任务执行状态
     * @param jobId 任务id
     * @param status 任务状态（0正常 1暂停）
     * @return
     */
    @PutMapping("/job/changeStatus")
    AjaxResult changeStatus(@Validated @RequestBody SysJob job);

    /**
     * 更改设备除状态采集的任务执行状态
     * @param sysJob
     */
    @PutMapping("/job/changeDeviceNoStateTask")
    R changeDeviceNoStateTask(@RequestBody List<SysJob> sysJob);

    /**
     * 新建设备时创建设备任务
     * @param projectId 项目id
     * @param productId 产品id
     * @param deviceId 设备id
     * @return
     */
    @PostMapping("/job/createDeviceTaskJob")
    R createDeviceTaskJob(@RequestParam("projectId") Long projectId,
                          @RequestParam("productId")Integer productId,
                          @RequestParam("deviceId")String deviceId);

    /**
     * 删除设备任务
     * @param deviceId
     * @return
     */
    @PostMapping("/job/delteDeviceJob")
    R delteDeviceJob(@RequestParam("deviceId") String deviceId);
}
